package com.lichongbing.lyoggl.config;

import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author lichongbing
 * @version 1.0.0
 * @createdate 2022/4/26 11:16 下午
 * @description: TODO
 */
public class Swagger3Config {
    private final OpenApiExtensionResolver openApiExtensionResolver;

    @Autowired
    public Swagger3Config(OpenApiExtensionResolver openApiExtensionResolver) {
        this.openApiExtensionResolver = openApiExtensionResolver;
    }

    @Bean
    public Docket taxationDocket() {
        return new Docket(DocumentationType.OAS_30)
                .groupName("service")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.lichongbing.lyoggl.controller"))
                .paths(PathSelectors.any())
                .build()
                .extensions(openApiExtensionResolver.buildExtensions("service"));
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("TimingService")
                .description("TimingService")
                .version("1.0.0")
                .contact(new Contact("lichongbing", "https://blog.lichongbing.com/doc.html", "873610008@qq.com"))
                .termsOfServiceUrl("https://www.lichongbing.com")
                .build();
    }

}

